package com.douleka.curd.service.impl;

import com.douleka.curd.entity.SupplyCard;
import com.douleka.curd.exception.MyException;
import com.douleka.curd.mapper.SupplyCardMapper;
import com.douleka.curd.service.ISupplyCardService;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.douleka.curd.utils.Page;
import com.douleka.curd.utils.Result;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.math.BigDecimal;
import java.math.BigInteger;
import java.text.ParseException;
import java.text.SimpleDateFormat;
import java.time.LocalDateTime;
import java.time.format.DateTimeFormatter;
import java.util.List;

/**
 * <p>
 * 卡密供货订单 服务实现类
 * </p>
 *
 * @author hg
 * @since 2024-03-19
 */
@Service
public class SupplyCardServiceImpl extends ServiceImpl<SupplyCardMapper, SupplyCard> implements ISupplyCardService {

    @Autowired
    private SupplyCardMapper supplyCardMapper;


    //根据条件查询获取订单
    @Override
    public Result<Object> getSupplyCardList(BigInteger userId, BigInteger cardNo, String batchId, String area, BigDecimal face, Integer status, String startTime, String endTime, Integer productType, Integer curr, Integer pageSize) {
        if (userId==null){
            throw new MyException("777","请先登录");
        }
        Integer totalCount = supplyCardMapper.getTotalCount(userId, cardNo, batchId, area, face, status, startTime, endTime,productType);
        Page<SupplyCard> page= new Page<>(curr,pageSize,totalCount);
        page.setList(supplyCardMapper.getSupplyCardList(userId, cardNo, batchId, area, face, status, startTime, endTime,productType,page.getStart(),page.getPageSize()));
        return new Result<>("200","success",page.getList());
    }
}
